Match = cc.Node.extend({
	ctor:function(p){
		this._super();
		p.addChild(this, 7, TAG_MATCH_NODE);
		this.loadMatch();
	},
	loadMatch : function(){
		var match = new Button(this, 10, TAG_MATCH, "#lamp/match.png",this.callback);
		match.setPosition(100,0);
	},
	lightMatch : function(next){
		var match = this.getChildByTag(TAG_MATCH);
		var fire = new cc.Sprite("#lamp/fire.png");
		fire.setAnchorPoint(cc.p(0, 0.5));
		fire.setPosition(-10,18);
		fire.setScale(0);
		match.addChild(fire);
		var seq = null;
		if(next){
			seq = cc.sequence(cc.scaleTo(0.3,1),this.getParent().callNext);
		} else {
			seq = cc.sequence(cc.scaleTo(0.3,1));
		}
		fire.runAction(seq)
	},
	lightLamp : function(){
		var ber = cc.bezierTo(1, [cc.p(20, 0),cc.p(100, -160),cc.p(90, -160)]);
		var delay = cc.delayTime(0.5);
		var func1 = cc.callFunc(function(){
			var lamp = this.getParent().getChildByTag(TAG_LAMP);
			lamp.loadFire();
		}, this);
		var func2 = cc.callFunc(function(){
			this.kill();
		}, this); 
		var seq = cc.sequence(ber, delay, func1, delay, this.getParent().callNext,func2);
		this.getChildByTag(TAG_MATCH).runAction(seq);
	},
	kill:function(){
		var seq = cc.sequence(cc.fadeOut(0.5),cc.callFunc(function(){
			this.removeFromParent(true);	
		}, this))
		this.runAction(seq);
	},
	callback:function(p){
		switch(p.getTag()){
		case TAG_MATCH:
			// 点燃酒精灯
			this.lightLamp();
			break;
		}
	}
});
